package linked;

/**
 * @author cooper
 * @date 2019-07-06
 */
public class SingleNode implements Cloneable, Comparable{

    int no;
    String name;
    SingleNode next;

    public SingleNode(int no){
        this(no, ""+no);
    }

    public SingleNode(int no, String name) {
        this.no = no;
        this.name = name;
    }

    @Override
    public String toString() {
        return "{" +
                "no=" + no +
                ", name='" + name + '\'' +
                '}';
    }

    @Override
    public int compareTo(Object o) {
        if (!(o instanceof SingleNode)){
            return 1;
        }
        SingleNode n = (SingleNode) o;
        return this.no - n.no;
    }

    public void setNext(SingleNode next) {
        this.next = next;
    }

    public void print(){
        System.out.println(this.toString());
    }
}
